package com.xiaoyu.client.adapter.forum;

import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.view.ViewGroup;

import com.xiaoyu.client.ui.fragment.forum.ForumFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by jk on 2018/10/18.
 */
public class ForumPagerAdapter extends FragmentStatePagerAdapter {
    private List<Fragment> mFragList = new ArrayList<>();
    private String[] categorys = new String[]{"high","lately","video","title","img"};

    public ForumPagerAdapter(FragmentManager fm,List<Fragment> list) {
        super(fm);
        this.mFragList = list;
    }

    @Override
    public Fragment getItem(int position) {
        return mFragList.get(position);
    }

    @Override
    public int getCount() {
        return mFragList.size();
    }

    @Override
    public int getItemPosition(@NonNull Object object) {
        return PagerAdapter.POSITION_NONE;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        ForumFragment fragment  = (ForumFragment) super.instantiateItem(container, position);
        fragment.updateArguments(categorys[position]);
        return fragment;
    }
}
